/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package similarite;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Clement
 */
public class SimCalc extends Thread {

    private List<List<Float>> s2;
    private List<List<Float>> s1;
    private List<List<Float>> aToB;
    private boolean ok;

    public List<List<Float>> getaToB() {
        return aToB;
    }

    public void setaToB(List<List<Float>> aToB) {
        this.aToB = aToB;
    }

    public boolean isOk() {
        return ok;
    }

    public void setOk(boolean ok) {
        this.ok = ok;
    }

    public SimCalc(SiftReader sa, SiftReader sb) {
        s1 = new ArrayList(sa.getResult());
        s2 = new ArrayList(sb.getResult());

        ok = false;
        aToB = new ArrayList();
    }

    @Override
    public void run() {
        for (List<Float> sA : s1) {
            float min = 0;
            int index = 0;
            boolean init = true;
            for (List<Float> sB : s2) {
                float r = MatrixOperation.getDistance(sA, sB);
                if (r < min || init) {
                    min = r;
                    index = s2.indexOf(sB);
                }
            }
            aToB.add(s2.get(index));
        }
        System.out.println("dFin");
        ok = true;
    }
}
